package com.zb.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zb.entity.TbSeckillGoodsModel;
import com.zb.mapper.TbSeckillGoodsMapper;
import com.zb.service.TbSeckillGoodsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @ClassName TbSeckillGoodsServiceImpl
 * @Description 服务接口实现
 * @Author zj
 * @Date 2022/11/16 09:31
 **/
@Service
public class TbSeckillGoodsServiceImpl extends ServiceImpl<TbSeckillGoodsMapper, TbSeckillGoodsModel> implements TbSeckillGoodsService {

    @Autowired
    private RedisTemplate redisTemplate;

    @Override
    public List<TbSeckillGoodsModel> list(String time) {
        List values = redisTemplate.boundHashOps("seckillGoods:" + time).values();
        return values;
    }

    @Override
    public TbSeckillGoodsModel get(String time, String id) {
        TbSeckillGoodsModel goodsModel = (TbSeckillGoodsModel) redisTemplate.boundHashOps("seckillGoods:" + time).get(id);
        return goodsModel;
    }
}
